@extends('admin.layout.base')
@section('styles')
@endsection
@section('content')
    <div class="panel-content" id="app" v-cloak>
        <div class="panel-body panel-info">
            <el-form :model="form" ref="form" class="form" label-width="100px" >
                <div class="panel-header"> <div class="panel-title"> 基本信息 </div> </div>
                <div class="panel-main">
                    <el-form-item label="头像：" prop="avatar"><img :src="form.avatar" style="height: 60px;width: 60px;border-radius: 50%"/></el-form-item>
                    <el-form-item label="类型：" prop="type"><el-input readonly v-model="form.type"></el-input></el-form-item>
                    <div v-if="form.type == 'HR'">
                        <el-form-item label="姓名：" prop="nickname"><el-input readonly v-model="form.nickname"></el-input></el-form-item>
                        <el-form-item label="邮箱：" prop="email"><el-input readonly v-model="form.email"></el-input></el-form-item>
                    </div>
                    <el-form-item label="手机号：" prop="mobile"><el-input readonly v-model="form.mobile"></el-input></el-form-item>
                    <el-form-item label="性别：" prop="sex"><el-input readonly v-model="form.sex"></el-input></el-form-item>
                    <el-form-item label="QQ：" prop="qq"><el-input readonly v-model="form.qq"></el-input></el-form-item>
                    <el-form-item label="公司名称：" prop="company_name"><el-input readonly v-model="form.user_info.company_name"></el-input></el-form-item>
                    <div v-if="form.type == 'HR'">
                        <el-form-item label="公司类型：" prop="company_type"><el-input readonly v-model="form.user_info.type"></el-input></el-form-item>
                        <el-form-item label="公司行业：" prop="company_industry"><el-input readonly v-model="form.user_info.industry"></el-input></el-form-item>
                        <el-form-item label="公司规模：" prop="company_size"><el-input readonly v-model="form.user_info.size"></el-input></el-form-item>
                        <el-form-item label="部门：" prop="hr_department"><el-input readonly v-model="form.user_info.hr_department"></el-input></el-form-item>
                        <el-form-item label="职位：" prop="hr_position"><el-input readonly v-model="form.user_info.hr_position"></el-input></el-form-item>
                    </div>
                    <div v-if="form.type == '供应商'">
                        <el-form-item label="微信：" prop="wechat"><el-input readonly v-model="form.wechat"></el-input></el-form-item>
                        <el-form-item label="区域：" prop="area"><el-input readonly v-model="form.area"></el-input></el-form-item>
                        <el-form-item label="公司邮箱：" prop="company_email"><el-input readonly v-model="form.user_info.company_email"></el-input></el-form-item>
                        <el-form-item label="负责人姓名：" prop="master_name"><el-input readonly v-model="form.user_info.master_name"></el-input></el-form-item>
                        <el-form-item label="组织机构代码：" prop="qrganization_code"><el-input readonly v-model="form.user_info.qrganization_code"></el-input></el-form-item>
                        <el-form-item label="营业执照：" prop="license">
                            <img :src="form.user_info.license" width="250" height="300" @click="handlePictureCardPreview(form.user_info.license)"/>
                            <el-dialog :visible.sync="dialogVisible"><img width="100%" :src="dialogImageUrl" alt=""></el-dialog>
                        </el-form-item>
                        <el-form-item label="资格证书：" prop="qualification">
                            <img v-for="item in form.user_info.qualification" :src="item" width="250" height="300" @click="handlePictureCardPreview(item)"/>
                            <el-dialog :visible.sync="dialogVisible"><img width="100%" :src="dialogImageUrl" alt=""></el-dialog>
                        </el-form-item>
                    </div>
                    <el-form-item label="状态：" prop="status">
                        <el-radio-group v-model="form.status">
                            <el-radio :label="1" border>正常</el-radio>
                            {{--<el-radio v-if="form.type != 'HR'" :label="2" border>待审核</el-radio>--}}
                            {{--<el-radio v-if="form.type != 'HR'" :label="3" border>未通过</el-radio>--}}
                            <el-radio :label="4" border>锁定</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item v-if="form.status != 1" label="原因：" prop="reason" :rules="[{ required: true, message: '请填写状态原因', trigger: 'blur'}]">
                        <el-input type="textarea" clearable v-model="form.reason"></el-input>
                    </el-form-item>
                </div>
                <div class="panel-header"> <div class="panel-title"> 财务信息 </div> </div>
                <div class="panel-main">
                    <el-form-item label="积分：" prop="integral">
                        <el-input clearable v-model="form.integral"></el-input>
                    </el-form-item>
                    <el-form-item label="余额：" prop="balance">
                        <el-input clearable v-model="form.balance"></el-input>
                    </el-form-item>
                    <div v-if="form.type == '供应商'">
                        <el-form-item label="保证金：" prop="bond">
                            <el-input clearable v-model="form.bond"></el-input>
                        </el-form-item>
                        <el-form-item label="收益：" prop="profit">
                            <el-input clearable v-model="form.profit"></el-input>
                        </el-form-item>
                        <el-form-item label="合同交易额：" prop="contract">
                            <el-input clearable v-model="form.contract"></el-input>
                        </el-form-item>
                        <el-form-item label="提现：" prop="cash">
                            <el-input clearable v-model="form.cash"></el-input>
                        </el-form-item>
                        <el-form-item label="会员费：" prop="member_fee">
                            <el-input clearable v-model="form.member_fee"></el-input>
                        </el-form-item>
                        <el-form-item label="会员费有效期：" prop="member_fee_at">
                            <el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss" v-model="form.member_fee_at" placeholder="会员费有效期"></el-date-picker>
                        </el-form-item>
                    </div>
                </div>
                <div class="panel-header"> <div class="panel-title"> 其他信息 </div> </div>
                <div class="panel-main">
                    <el-form-item label="注册时间：" prop="created_at">
                        <el-input readonly v-model="form.created_at"></el-input>
                    </el-form-item>
                    <el-form-item label="注册IP：" prop="register_ip">
                        <el-input readonly v-model="form.register_ip"></el-input>
                    </el-form-item>
                    <el-form-item label="最近登录：" prop="login_at">
                        <el-input readonly v-model="form.login_at"></el-input>
                    </el-form-item>
                    <el-form-item label="登录IP：" prop="login_ip">
                        <el-input readonly v-model="form.login_ip"></el-input>
                    </el-form-item>
                    <el-form-item label="最近更新：" prop="updated_at">
                        <el-input readonly v-model="form.updated_at"></el-input>
                    </el-form-item>
                </div>
                <el-form-item style="padding-left: 150px;margin-top: 100px">
                    <el-button type="primary" @click="update()">保 存</el-button>
                    <el-button @click="back()" style="margin-left: 50px">返 回</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
@endsection
@section('scripts')
    <script>
        let app = new Vue({
            el: '#app',
            data: function() {
                return {
                    form:{!! $info !!},
                    dialogImageUrl: '',
                    dialogVisible: false,
                }
            },
            created(){
                this.form.password = '';
                this.form.reason = '';
                this.form._token = "{{csrf_token()}}";
            },
            methods: {
                //返回
                back(){
                    window.history.go(-1);
                },
                //图片放大
                handlePictureCardPreview(file) {
                    this.dialogImageUrl = file;
                    this.dialogVisible = true;
                },
                //更新
                update(){
                    this.$refs['form'].validate((valid) => {
                        if (valid) {
                            let that = this;
                            $.post("{{ route('admin.user.update') }}",this.form,function (res) {
                                if(res.code){
                                    that.$message.error(res.msg);
                                }else{
                                    that.$message({
                                        type: 'success',
                                        duration: '1000',
                                        message: res.msg,
                                        onClose:() =>{
                                            window.history.go(-1);
                                        }
                                    });
                                }
                            },'JSON');
                        }
                    });
                },
            }
        });
    </script>
@endsection
